var baseUrl = 'https://chifresh.cn';
function getReq(url, data, cb) {
  data.userid = wx.getStorageSync('hhh');
  wx.request({
    url: baseUrl + url,
    data: data,
    method: 'GET',
    header: { 'Content-Type': 'application/json' },
    success: function (res) {
      return typeof cb == "function" && cb(res.data)
    },
    fail: function () {
      return typeof cb == "function" && cb(false);   
    }
  })
}

function postReq(url, data, cb) {
  var userid = wx.getStorageSync('hhh');
  if(userid){
    data.userid=userid;
    // data.userid=275;
  }
  wx.request({
    url: baseUrl + url,
    data: data,
    method: 'POST',
    header: { 'Content-Type': 'application/x-www-form-urlencoded' },
    success: function (res) {
      return typeof cb == "function" && cb(res.data)
    },
    fail: function () {
      return typeof cb == "function" && cb(false);
    }
  })
}
module.exports = {
  getReq: getReq,
  postReq: postReq
} 